﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web.UI;
using Org.Eurekaa.DNJ.Settings;

namespace Org.Eurekaa.DNJ.UI.DNJSettings
{
    [TypeConverter(typeof(ExpandableObjectConverter))]
    [Serializable()]
    public class DNJTabsSettings : GenericSettingsObject
    {
        [Description("The HTML content of this string is shown in a tab title while remote content is loading. Pass in empty string to deactivate that behavior.")]
        [DefaultValue(""), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public string Spinner
        {
            get { return this.Get<string>("spinner"); }
            set { this["spinner"] = value; }
        }

        [Description("Whether or not to cache remote tabs content, e.g. load only once or with every click. Cached content is being lazy loaded, e.g once and only once for the first click. Note that to prevent the actual Ajax requests from being cached by the browser you need to provide an extra cache: false flag to ajaxOptions.")]
        [DefaultValue(false), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public bool Cache
        {
            get { return this.Get<bool>("cache"); }
            set { this["cache"] = value; }
        }

        [Description("Set to true to allow an already selected tab to become unselected again upon reselection.")]
        [DefaultValue(false), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public bool Collapsible
        {
            get { return this.Get<bool>("collapsible"); }
            set { this["collapsible"] = value; }
        }

        [Description("Zero-based index of the tab to be selected on initialization. To set all tabs to unselected pass -1 as value.")]
        [DefaultValue(0), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public int Selected
        {
            get { return this.Get<int>("selected"); }
            set { this["selected"] = value; }
        }



        private DNJCoookieSettings _cookie = new DNJCoookieSettings();
        [Description("")]
        [PersistenceMode(PersistenceMode.Attribute),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public DNJCoookieSettings Cookie
        {
            get { return _cookie; }
            set { _cookie = value; }
        }        
        public DNJTabsSettings()
        {
        }

        public override void PrepareJSON()
        {
            if (this.Cookie.Expires > 0) this["cookie"] = Cookie;
        }
    }
}
